package cn.config;

import cn.domain.Clazz;
import cn.domain.Stu;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
@ComponentScan("cn")
public class JavaConfig {
    @Bean({"jee-stu","haut-stu"})
    public Stu stu(){
        Stu stu=new Stu("zhang",21);
        return stu;
    }
    @Bean
    public Clazz clazz(){
        Clazz clazz=new Clazz();
        clazz.setStu(stu());
        clazz.setName("se");
        return clazz;
    }
    @Bean
    public DataSource dataSource(){
        HikariDataSource dataSource=new HikariDataSource();
        dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
        dataSource.setJdbcUrl("jdbc:hsqldb:hsql://localhost/");
        dataSource.setUsername("sa");
        dataSource.setPassword("");
        return dataSource;
    }
}
